<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <script type="text/javascript" src="../../jClass.js"></script>
    <script type="text/javascript" src="../jquery.js"></script>
    <script type="text/javascript">

        include("/libraries/jclass/graphics/p3d.js");

        (function($) {
            $(document).ready(function() {

                function load_binary_resource(url) {
                  var req = new XMLHttpRequest();
                  req.open('GET', url, false);
                  //XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
                  req.overrideMimeType('text/plain; charset=x-user-defined');
                  req.send(null);
                  if (req.status != 200) return '';
                  return req.responseText;
                }

                var canvas = document.getElementById('myCanvas');
                var p3d = new jclass.graphics.p3d.P3D(canvas, load_binary_resource('../assets/truncated_icosidodecahedron.p3d'));

                $("#source").change(function() {
                    var opt = $(this).val();
                    $("option").each(function(obj) {
                        if ($(this).val() == opt) {
                            p3d.Load(load_binary_resource('../assets/' + $(this).attr('name')))
                        }
                    })
                })
            });
        })(jQuery)
    </script>
    <link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>

<label>Source</label>
<select id="source">
    <option name="cube.p3d">Cube</option>
    <option name="tetrahedron.p3d">Tetrahedron</option>
    <option name="truncated_icosidodecahedron.p3d">Truncated Icosidodecahedron</option>
</select><br />

<canvas id="myCanvas" width="300" height="300">No canvas support</canvas>

</body>
</html>
